package cn.stylefeng.guns.sys.modular.system.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.sys.core.util.UUIDUtils;
import cn.stylefeng.guns.sys.modular.system.entity.*;
import cn.stylefeng.guns.sys.modular.system.entity.Enum.AttendAuditStatusEnum;
import cn.stylefeng.guns.sys.modular.system.model.params.*;
import cn.stylefeng.guns.sys.modular.system.model.result.AttendAuditManagerSetResult;
import cn.stylefeng.guns.sys.modular.system.model.result.AttendAuditResult;
import cn.stylefeng.guns.sys.modular.system.model.result.AttendEmployeeMonthAddValidationResult;
import cn.stylefeng.guns.sys.modular.system.service.*;
import cn.stylefeng.guns.sys.modular.system.entity.Enum.EmployeePositionEnum;
import cn.stylefeng.guns.sys.modular.system.model.result.AttendAuditBtyArchivesCountShop;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.roses.core.util.ToolUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 出勤_督导审核店长表控制器
 *
 * @author wjk
 * @Date 2021-09-14 16:48:46
 */
@Controller
@RequestMapping("/attendAudit")
public class AttendAuditController extends BaseController {

    private String PREFIX = "/modular/system/attendAudit";

    /**
     * 跳转到主页面
     *
     * @author wjk
     * @Date 2021-11-15
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/attendAudit.html";
    }



    @Autowired
    private AttendAuditService attendAuditService;

    /**
     * 这是yingye的人员档案信息类
     */
    @Autowired
    private AttendAuditBtyArchivesService attendAuditBtyArchivesService;

    /**
     * 这是yingye的督导指定店长的服务类
     */
    @Autowired
    private AttendAuditBtyAreaService attendAuditBtyAreaService;

    /**
     * 这是月度员工档案服务类
     */
    @Autowired
    private AttendEmployeeMonthService attendEmployeeMonthService;


    /**
     * 这是驳回数据类
     */
    @Autowired
    private AttendDismissedService attendDismissedService;


    /**
     * 查看详情接口
     *
     * @author wjk
     * @Date 2021-09-14
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(AttendAuditParam attendAuditParam) {
        AttendAudit detail = this.attendAuditService.getById(attendAuditParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author wjk
     * @Date 2021-09-14
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(AttendAuditParam attendAuditParam) {
        return this.attendAuditService.findPageBySpec(attendAuditParam);
    }

    /**
     * 查询所有人员档案信列表
     *
     * @author wjk
     * @Date 2021-09-14
     */
    @ResponseBody
    @RequestMapping("/btyArchiveslist")
    public LayuiPageInfo btyArchiveslist(AttendAuditBtyArchivesParam param) {
        return this.attendAuditBtyArchivesService.findPageBySpec(param);
    }

    /**
     * 获取列表(这是为了同步相应月份的数据，获取当月的员工档案数据)
     *
     * @author wjk
     * @Date 2021-09-15
     */
    @ResponseBody
    @RequestMapping("/getAttendEmployeeMonthBaseList")
    public List<AttendEmployeeMonth> getAttendEmployeeMonthBaseList(AttendEmployeeMonthParam paramCondition){
        return this.attendAuditBtyArchivesService.getAttendEmployeeMonthBaseList(paramCondition);
    }

    /**
     *  月度同步信息表
     * @author wjk
     * @Date 2021-09-15
     */
//    @ResponseBody
//    @RequestMapping("/intoAttendEmployeeMonthList")
//    public ResponseData intoAttendEmployeeMonthList(){
//        int size = this.attendAuditBtyArchivesService.intoAttendEmployeeMonthList();
//        return ResponseData.success("本月成功同步"+size+"条数据");
//    }
    /**
     * （督导设置店长页面）根据督导的手机号码，返回督导下的所有的店；
     * @author wjk
     * @Date 2021-09-15
     */
    @ResponseBody
    @RequestMapping("/getShopListByDdPhone")
    public ResponseData getShopListByDdPhone(String account,String shopName){
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"失败,缺少有效的手机号!",new ArrayList<AttendAuditBtyArea>());
        }
        List<AttendAuditBtyArea> list = this.attendAuditBtyArchivesService.getShopListByDdPhone(account,shopName);
        return ResponseData.success(list);

    }

    /**
     * （督导设置店长页面）根据督导的手机号码，返回督导下的所有的店-分页；
     * @author wjk
     * @Date 2021-11-19
     */
    @ResponseBody
    @RequestMapping("/getShopListByDdPhoneLayuiPage")
    public ResponseData getShopListByDdPhoneLayuiPage(String account,String shopName){
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            LayuiPageInfo LayuiPageInfoNew = new LayuiPageInfo();
            LayuiPageInfoNew.setData(new ArrayList<AttendAuditBtyArea>());
            return ResponseData.error(200,"失败,缺少有效的手机号!",LayuiPageInfoNew);
        }
        LayuiPageInfo layuiPageInfo = this.attendAuditBtyArchivesService.getShopListByDdPhoneLayuiPage(account,shopName);
        return ResponseData.success(layuiPageInfo);

    }

    /**
     * （督导设置店长页面）根据店名，获取店的员工列表；
     * @author wjk
     * @Date 2021-09-15
     */
    @ResponseBody
    @RequestMapping("/getEmployeeListByDm")
    public ResponseData getEmployeeListByDm(String account,String dm){
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"失败,缺少有效的手机号!",new ArrayList<AttendAuditBtyArchives>());
        }
        if (ToolUtil.isEmpty(dm)) {
            return ResponseData.error(200,"失败,缺少有效的店名!",new ArrayList<AttendAuditBtyArchives>());
        }
        List<AttendAuditBtyArchives> list = this.attendAuditBtyArchivesService.getEmployeeListByDm(dm,account);
        return ResponseData.success(list);
    }
    /**
     * （督导设置店长页面）根据店名，获取店的员工列表；
     * @author wjk
     * @Date 2021-09-15
     */
    @ResponseBody
    @PostMapping("/getEmployeeListByDmPost")
    public ResponseData getEmployeeListByDmPost(@RequestBody AttendAuditDdSupervisorParam attendAuditDdSupervisorParam,String account){
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"失败,缺少有效的手机号!",new ArrayList<AttendAuditBtyArchives>());
        }
        if (ToolUtil.isEmpty(attendAuditDdSupervisorParam.getShopName())) {
            return ResponseData.error(200,"失败,缺少有效的店名!",new ArrayList<AttendAuditBtyArchives>());
        }
        List<AttendAuditBtyArchives> list = this.attendAuditBtyArchivesService.getEmployeeListByDm(attendAuditDdSupervisorParam.getShopName(),account);
        return ResponseData.success(list);
    }
    /**
     * （督导设置店长页面）指定店长员工信息，督导手机号，设置店长；
     * @author wjk
     * @Date 2021-09-15
     */
    @ResponseBody
    @RequestMapping("/setEmployeeToDz")
    public ResponseData setEmployeeToDz(AttendAuditBtyArchivesParam attendAuditBtyArchivesParam,String account){

        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的督导或者大店长手机号!",new ArrayList<AttendAuditBtyArchives>());
        }
        if (ToolUtil.isEmpty(attendAuditBtyArchivesParam)||ToolUtil.isEmpty(attendAuditBtyArchivesParam.getId())) {
            return ResponseData.error(200,"缺少有效的将要设置店长的员工信息!",new ArrayList<AttendAuditBtyArchives>());
        }

        //boolean flag = attendAuditBtyAreaService.setEmployeeToDz(attendAuditBtyArchivesParam,account);
        Map<String,String> map = attendAuditBtyAreaService.setEmployeeToDz(attendAuditBtyArchivesParam,account);
        if(map.get("flag").equals("true")){
            return ResponseData.success(200,map.get("message"),true);
        }else{
            return ResponseData.error(200,map.get("message"),false);
        }

    }

    /**
     * （督导设置店长页面）根据督导的手机号码，返回督导的手机号，职位，所拥有的店的汇总；
     * @author wjk
     * @Date 2021-09-16
     */
    @ResponseBody
    @RequestMapping("/getShopCountShopByDdPhone")
    public ResponseData getShopCountShopByDdPhone(String account){
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号。",new AttendAuditBtyArchivesCountShop());
        }
        AttendAuditBtyArchivesCountShop attendAuditBtyArchivesCountShop = this.attendAuditBtyArchivesService.getShopCountShopByDdPhone(account);
        return ResponseData.success(attendAuditBtyArchivesCountShop);
    }

    /**
     * （店长创建考勤页面）根据店长的手机号码，店长旗下店的信息；
     * @author wjk
     * @Date 2021-09-16
     */
    @ResponseBody
    @RequestMapping("/getShopInfoByDzPhone")
    public ResponseData getShopInfoByDzPhone(String account){
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号。",new AttendAuditBtyArea());
        }
        AttendAuditBtyArea attendAuditBtyArea = this.attendAuditBtyAreaService.getShopInfoByDzPhone(account);
        if (ToolUtil.isEmpty(attendAuditBtyArea)||ToolUtil.isEmpty(attendAuditBtyArea.getId())||ToolUtil.isEmpty(attendAuditBtyArea.getDm())) {
            return ResponseData.error(200, "未找到您账号下店信息。", attendAuditBtyArea);
        } else {
            return ResponseData.success(attendAuditBtyArea);
        }
    }

    /**
     * （店长创建考勤页面）根据店长的手机号码，返回店长下来自人资的档案的列表；
     * @author wjk
     * @Date 2021-09-16
     * 增加店长显示店员为空的情况时，查询错误原因，返回给前端显示。
     * updateDate 2021-09-16
     */
    @ResponseBody
    @RequestMapping("/getEmployeeListByDzPhone")
    public ResponseData getEmployeeListByDzPhone(String account){
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号。",new ArrayList<AttendAuditBtyArchives>());
        }
        List<AttendAuditBtyArchives> list = this.attendAuditBtyArchivesService.getEmployeeListByDzPhone(account);
        if(list.size()>0){
            return ResponseData.success(list);
        } else {
            //根据考勤店长手机号，未获取员工信息的原因的提示！
            Map<String,String> map = this.attendAuditBtyArchivesService.getEmployeeListNullProblem(account,list);
            return ResponseData.error(200, map.get("message"), list);
        }
    }

    /**
     * （店长创建考勤页面）根据店长的手机号码，创建该店人员的[月度]考勤信息；
     * @author wjk
     * @Date 2021-09-16
     * 增加创建考勤查询错误原因，返回给前端显示。
     * updateDate 2021-09-16
     */
    @ResponseBody
    @RequestMapping("/setEmployeeListByDzPhone")
    public ResponseData setEmployeeListByDzPhone(String account,String attendMonth){
        Map<String,String> map = this.attendAuditService.getCreateAttendButton();
        if(!"0".equals(map.get("buttonValid"))){
            return ResponseData.error(200, ""+map.get("AttendDaysNotes"));
        }
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号。",new ArrayList<AttendAuditBtyArchives>());
        }
        int size = this.attendAuditBtyArchivesService.intoAttendEmployeeMonthListByDzPhone(account,attendMonth);
        if(size>0){
            return ResponseData.success(size);
        }else{
            return ResponseData.error(200, "创建考勤失败，该店人员考勤已被创建或者已被调走。", size);
        }
    }


//    /**
//     * （店长考勤修改页面）根据店长的手机号码，返回店长下的所有的人员（当月）档案的列表；
//     * @author wjk
//     * @Date 2021-09-15
//     */
//    @ResponseBody
//    @RequestMapping("/getEmployeeListMonthByDzPhone")
//    public ResponseData getEmployeeListMonthByDzPhone(String account){
//        List<AttendEmployeeMonth> list = this.attendEmployeeMonthService.getEmployeeListMonthByDzPhone(account);
//        return ResponseData.success(list);
//    }


    /**
     * （店长考勤修改页面）根据店长的手机号码，返回该店的店长，所有的审核信息；
     * @author wjk
     * @Date 2021-09-17
     */
    @ResponseBody
    @RequestMapping("/getEmployeeListMonthByManagerSetParam")
    public ResponseData getEmployeeListMonthByManagerSetParam(AttendAuditManagerSetParam param){
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(param.getAccount())) {
            return ResponseData.error(200,"缺少有效的手机号。",new ArrayList<AttendAuditManagerSetResult>());
        }
        List<AttendAuditManagerSetResult> list =  this.attendEmployeeMonthService.getEmployeeListMonthByManagerSetParam(param);
        return ResponseData.success(list);
    }

    /**
     * （店长考勤修改页面）编辑员工的出勤天数，公休天数，应发工资数，是否在职，是否发工资信息，以及备注1
     *
     *
     * @author wjk
     * @Date 2021-09-14
     * 增加验证，店长手机号，增加修改gw,gz,zw
     * updateDate 2021-11-08
     */
    @ResponseBody
    @PostMapping("/updateAttendEmployeeMonthById")
    public ResponseData updateAttendEmployeeMonthById(@RequestBody AttendEmployeeMonthParam attendEmployeeMonthParam,String account) {
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号。",false);
        }
        boolean falg = this.attendEmployeeMonthService.updateAttendEmployeeMonthById(attendEmployeeMonthParam,account);
        if(falg){
            return ResponseData.success(falg);
        }else{
            return ResponseData.error(200,"失败。",falg);
        }

    }

    /**
     * （店长考勤修改页面）编辑员工的工资验证，若能查找到老员工信息，返回给前端老员工的信息，供前端赋值
     *
     *
     * @author wjk
     * @Date 2021-09-11
     * 增加验证，店长手机号，增加修改gw,gz,zw
     * updateDate 2021-11-11
     */
    @ResponseBody
    @PostMapping("/updateAttendEmployeeMonthByIdValidation")
    public ResponseData updateAttendEmployeeMonthByIdValidation(@RequestBody AttendEmployeeMonthParam attendEmployeeMonthParam,String account) {
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号。",false);
        }
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(attendEmployeeMonthParam.getBtyArchicesId())) {
            return ResponseData.error(200,"缺少有效的员工信息。",false);
        }
        AttendAuditBtyArchivesParam attendAuditBtyArchives = new AttendAuditBtyArchivesParam();
        attendAuditBtyArchives.setId(attendEmployeeMonthParam.getBtyArchicesId().intValue());
        AttendAuditBtyArchives attendAuditBtyArchivesOld =  attendAuditBtyArchivesService.detailById(attendAuditBtyArchives);
        if(ToolUtil.isNotEmpty(attendAuditBtyArchivesOld)){
            return ResponseData.success(200,"成功。",attendAuditBtyArchivesOld);
        }else{
            return ResponseData.success(200,"失败。",new AttendAuditBtyArchives());
        }

    }

    /**
     * （店长考勤修改页面）编辑当员工工资为0或者空的时候允许编辑员工的工资
     *
     *
     * @author wjk
     * @Date 2021-10-18
     */
    @ResponseBody
    @PostMapping("/updateAttendEmployeeMonthForGzById")
    public ResponseData updateAttendEmployeeMonthForGzById(@RequestBody AttendEmployeeMonthParam attendEmployeeMonthParam) {
        boolean falg = this.attendEmployeeMonthService.updateAttendEmployeeMonthForGzById(attendEmployeeMonthParam);
        if(falg){
            return ResponseData.success(falg);
        }else{
            return ResponseData.error(200,"员工工资不为0，不允许修改薪资",falg);
        }

    }

    /**
     * （店长考勤修改页面）店长提交该审核信息
     *
     *
     * @author wjk
     * @Date 2021-09-17
     */

    @ResponseBody
    @RequestMapping("/managerSubmitAuditByPhoneAndId")
    public ResponseData managerSubmitAuditByPhoneAndId(String account,String aaId) {
        //店长提交审核，先验证手机号，在验证aaId，在验证旗下有没有数据所有都符合要求
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号。",false);
        }
        //若考勤id，直接返回
        if (ToolUtil.isEmpty(aaId)) {
            return ResponseData.error(200,"缺少信息，无法查询到考勤信息。",false);
        }

        Map<String,String> map = this.attendAuditService.managerSubmitAuditByPhoneAndIdValidation(account,aaId);
        if(map.get("flag").equals("false")){
            return ResponseData.error(200,map.get("message"),map.get("flag"));
        }
        boolean falg = this.attendAuditService.managerSubmitAuditByPhoneAndId(account,aaId);
        if(falg){
            return ResponseData.success(falg);
        }else{
            return ResponseData.error(200,"失败。",falg);
        }

    }

    /**
     * （店长考勤修改页面+新增员工信息） 增加员工信息的验证消息
     *
     * @author wjk
     * @Date 2021-11-08
     *
     */
    @ResponseBody
    @PostMapping("/addAttendEmployeeMonthValidation")
    public ResponseData addAttendEmployeeMonthValidation(@RequestBody AttendEmployeeMonthParam attendEmployeeMonthParam,String account) {
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号。",new AttendEmployeeMonthAddValidationResult());
        }
        //添加新员工的验证信息
        AttendEmployeeMonthAddValidationResult attendEmployeeMonthAddValidationResult = this.attendEmployeeMonthService.addAttendEmployeeMonthValidation(attendEmployeeMonthParam,account);
        return ResponseData.success(200,"成功！",attendEmployeeMonthAddValidationResult);
    }

    /**
     * （店长考勤修改页面+新增员工信息） 根据编号同步，单个人员的信息，若已经同步，则返回同步后的信息
     *
     * @author wjk
     * @Date 2021-11-08
     *
     */
    @ResponseBody
    @PostMapping("/synchronousOneAttendEmployeeMonthByBh")
    public ResponseData synchronousOneAttendEmployeeMonthByBh(String account,@RequestBody AttendEmployeeMonthAddValidationResult attendEmployeeMonthAddValidationResult) {
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号。",new AttendEmployeeMonth());
        }
        //同步之后，返回已经同步员工的状态信息
        AttendEmployeeMonth attendEmployeeMonth = this.attendEmployeeMonthService.synchronousOneAttendEmployeeMonthByBh(account,attendEmployeeMonthAddValidationResult);
        if(ToolUtil.isNotEmpty(attendEmployeeMonth)&&ToolUtil.isNotEmpty(attendEmployeeMonth.getId())){
            return ResponseData.success(200,"成功！",attendEmployeeMonth);
        }else{
            return ResponseData.error(200,"失败！",attendEmployeeMonth);
        }

    }


    /**
     * （店长考勤修改页面 + 新增员工信息） 增加员工信息
     *
     *
     * @author wjk
     * @Date 2021-09-17
     */
    @ResponseBody
    @PostMapping("/addAttendEmployeeMonth")
    public ResponseData addAttendEmployeeMonth(@RequestBody AttendEmployeeMonthParam attendEmployeeMonthParam,String account) {
        boolean falg = this.attendEmployeeMonthService.addAttendEmployeeMonth(attendEmployeeMonthParam,account);
        if(falg){
            return ResponseData.success(falg);
        }else{
            return ResponseData.error(200,"重复的身份证或者手机号，请选择是调店，或者同步",falg);
        }

    }

    /**
     * （店长考勤修改页面+新增员工信息） 返回职位列表
     *
     *
     * @author wjk
     * @Date 2021-09-17
     */
    @ResponseBody
    @RequestMapping("/getEmployeePosition")
    public ResponseData getEmployeePosition() {
        String[] employeeMonth = EmployeePositionEnum.POSITIONALL.getMsg().split(",");
        return ResponseData.success(employeeMonth);
    }

    /**
     * （店长考勤修改页面+新增员工信息） 修改员工信息
     *
     *
     * @author wjk
     * @Date 2021-09-17
     */
    @ResponseBody
    @PostMapping("/updateAttendEmployeeMonth")
    public ResponseData updateAttendEmployeeMonth(@RequestBody AttendEmployeeMonthParam attendEmployeeMonthParam,String account) {
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号。",false);
        }
        boolean falg = this.attendEmployeeMonthService.updateAttendEmployeeMonthById(attendEmployeeMonthParam,account);
        //boolean falg = this.attendEmployeeMonthService.updateAttendEmployeeMonth(attendEmployeeMonthParam);
        if(falg){
            return ResponseData.success(falg);
        }else{
            return ResponseData.error(200,"失败。",falg);
        }
    }

    /**
     * （店长考勤修改页面+新增员工信息）删除员工信息，根据店长的电话 和 员工的id
     *
     *
     * @author wjk
     * @Date 2021-09-18
     */
    @ResponseBody
    @RequestMapping("/deleteAttendEmployeeMonth")
    public ResponseData deleteAttendEmployeeMonth(String account,String id) {
        boolean falg = this.attendEmployeeMonthService.deleteAttendEmployeeMonth(account,id);
        if(falg){
            return ResponseData.success(falg);
        }else{
            return ResponseData.error(200,"失败",falg);
        }
    }
    /**
     * （店长考勤修改页面+员工调店） 根据店长手机号，查询店长的运营经理，下的店的员工信息
     *
     *
     * @author wjk
     * @Date 2021-09-17
     */
    @ResponseBody
    @RequestMapping("/getOperationsEmployeeListByDzPhone")
    public ResponseData getOperationsEmployeeListByDzPhone(String account,String xm){
        List<AttendAuditBtyArchives> list = this.attendAuditBtyArchivesService.getOperationsEmployeeListByDzPhone(account,xm);
        return ResponseData.success(list);
    }

    /**
     * （店长考勤修改页面+员工调店） 根据店长手机号，查询店长的运营经理，下的店的员工信息，增加分页接口数据
     *
     *
     * @author wjk
     * @Date 2021-11-18
     */
    @ResponseBody
    @RequestMapping("/getOperationsEmployeeListByDzPhoneLayuiPage")
    public ResponseData getOperationsEmployeeListByDzPhoneLayuiPage(String account,String xm){
        LayuiPageInfo layuiPageInfo = this.attendAuditBtyArchivesService.getOperationsEmployeeListByDzPhoneLayuiPage(account,xm);
        return ResponseData.success(layuiPageInfo);
    }

    /**
     * （店长考勤修改页面+员工调店） 根据店长手机号，和员工id将员工调入店长下的店
     *
     *
     * @author wjk
     * @Date 2021-09-17
     */
    @ResponseBody
    @PostMapping("/setEmployeeToShop")
    public ResponseData setEmployeeToShop(@RequestBody AttendAuditBtyArchivesParam attendAuditBtyArchivesParam ,String account){
        String resultStr = this.attendEmployeeMonthService.setEmployeeToShop(account,attendAuditBtyArchivesParam);
        return ResponseData.success(resultStr);
    }

    /**
     * （督导审核页面）根据督导的手机号码，返回该店的督导所有的审核信息；
     * @author wjk
     * @Date 2021-09-18
     */
    @ResponseBody
    @RequestMapping("/getEmployeeListMonthByDdSupervisorParam")
    public ResponseData getEmployeeListMonthByDdSupervisorParam(AttendAuditDdSupervisorParam param){
        List<AttendAuditManagerSetResult> list =  this.attendEmployeeMonthService.getEmployeeListMonthByDdSupervisorParam(param);
        return ResponseData.success(list);
    }

    /**
     * （督导审核页面）根据督导的手机号码，返回该店的督导所有的审核信息；
     * @author wjk
     * @Date 2021-09-18
     */
    @ResponseBody
    @PostMapping("/getEmployeeListMonthByDdSupervisorParamPost")
    public ResponseData getEmployeeListMonthByDdSupervisorParamPost(@RequestBody AttendAuditDdSupervisorParam param,String account){
        if(ToolUtil.isEmpty(param.getAccount())){
            param.setAccount(account);
        }
        List<AttendAuditManagerSetResult> list =  this.attendEmployeeMonthService.getEmployeeListMonthByDdSupervisorParam(param);
        return ResponseData.success(list);
    }

    /**
     * （运营经理审核页面）根据运营经理的手机号码，返回该店的督导所有的审核信息；
     * @author wjk
     * @Date 2021-09-19
     */
    @ResponseBody
    @RequestMapping("/getEmployeeListMonthByYyjlSupervisorParam")
    public ResponseData getEmployeeListMonthByYyjlSupervisorParam(AttendAuditDdSupervisorParam param){
        List<AttendAuditManagerSetResult> list =  this.attendEmployeeMonthService.getEmployeeListMonthByYyjlSupervisorParam(param);
        return ResponseData.success(list);
    }

    /**
     * （运营经理审核页面）根据运营经理的手机号码，返回该店的督导所有的审核信息；
     * @author wjk
     * @Date 2021-09-19
     */
    @ResponseBody
    @PostMapping("/getEmployeeListMonthByYyjlSupervisorParamPost")
    public ResponseData getEmployeeListMonthByYyjlSupervisorParamPost(@RequestBody AttendAuditDdSupervisorParam param,String account){
        if(ToolUtil.isEmpty(param.getAccount())){
            param.setAccount(account);
        }
        List<AttendAuditManagerSetResult> list =  this.attendEmployeeMonthService.getEmployeeListMonthByYyjlSupervisorParam(param);
        return ResponseData.success(list);
    }

    /**
     * （运营经理审核页面）根据运营经理的手机号码，返回该店的督导所有的审核信息-分页；
     * @author wjk
     * @Date 2021-11-19
     */
    @ResponseBody
    @RequestMapping("/getEmployeeListMonthByYyjlSupervisorParamLayuiPage")
    public ResponseData getEmployeeListMonthByYyjlSupervisorParamLayuiPage(AttendAuditDdSupervisorParam param){
        LayuiPageInfo layuiPageInfo = this.attendEmployeeMonthService.getEmployeeListMonthByYyjlSupervisorParamLayuiPage(param);
        return ResponseData.success(layuiPageInfo);
    }


    /**
     * （运营经理审核页面）根据运营经理的手机号码，返回该店的督导所有的审核信息-分页；
     * @author wjk
     * @Date 2021-11-23
     */
    @ResponseBody
    @PostMapping("/getEmployeeListMonthByYyjlSupervisorParamLayuiPagePost")
    public ResponseData getEmployeeListMonthByYyjlSupervisorParamLayuiPagePost(@RequestBody AttendAuditDdSupervisorParam param,String account){
        if(ToolUtil.isEmpty(param.getAccount())){
            param.setAccount(account);
        }
        LayuiPageInfo layuiPageInfo = this.attendEmployeeMonthService.getEmployeeListMonthByYyjlSupervisorParamLayuiPage(param);
        return ResponseData.success(layuiPageInfo);
    }

    /**
     * （督导审核页面）督导审核，通过；
     * @author wjk
     * @Date 2021-09-18
     */
    @ResponseBody
    @PostMapping("/setAttendAuditApproveByEmployeeList")
    public ResponseData setAttendAuditApproveByEmployeeList(@RequestBody List<AttendAuditManagerSetResult> param,String account){
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号",false);
        }
        boolean falg = this.attendAuditService.setAttendAuditApproveByEmployeeList(param,account);
        if(falg){
            return ResponseData.success(falg);
        }else{
            return ResponseData.error(200,"失败",falg);
        }
    }

    /**
     * （督导审核页面）督导审核，驳回；
     * @author wjk
     * @Date 2021-09-18
     */
    @ResponseBody
    @PostMapping("/setAttendAuditBackByEmployeeList")
    public ResponseData setAttendAuditBackByEmployeeList(@RequestBody List<AttendAuditManagerSetResult> param,String account){
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号。",false);
        }
        boolean falg = this.attendAuditService.setAttendAuditBackByEmployeeList(param,account);
        if(falg){
            return ResponseData.success(falg);
        }else{
            return ResponseData.error(200,"失败",falg);
        }
    }


    /**
     * （督导审核页面）设置督导审核，驳回,一个总的驳回；
     * @author wjk
     * @Date 2021-09-19
     */
    @ResponseBody
    @PostMapping("/setAttendAuditBackByDismissed")
    public ResponseData setAttendAuditBackByDismissed(@RequestBody  AttendAuditDdSupervisorParam param,String account,String shopName){
        AttendDismissed attendDismissedParam = new AttendDismissed();
        attendDismissedParam.setDismissedNote(param.getDismissedNote());
        AttendDismissed attendDismissed = attendDismissedService.addAttendDismissed(attendDismissedParam,account,param.getShopName());
        return ResponseData.success(attendDismissed);
    }


    /**
     * （督导审核页面）获取督导审核，驳回,一个总的驳回；
     * @author wjk
     * @Date 2021-09-19
     */
    @ResponseBody
    @PostMapping("/getAttendAuditBackByDismissed")
    public ResponseData getAttendAuditBackByDismissed(@RequestBody  AttendAuditDdSupervisorParam param,String account){
        AttendDismissed attendDismissed = attendDismissedService.getAttendDismissed(account,param.getShopName());
        return ResponseData.success(attendDismissed);
    }

    /**
     * （督导审核页面）根据督导选择店，月份，返回计算的（待审核，加上已审核通过的人员的应发工资总数）；
     * @author wjk
     * @Date 2021-09-18
     */
    @ResponseBody
    @RequestMapping("/getShouldPayByDdSupervisor")
    public ResponseData getShouldPayByDdSupervisor(AttendAuditDdSupervisorParam param){
        Map<String,String> map = this.attendEmployeeMonthService.getShouldPayByDdSupervisor(param);
        return ResponseData.success(map);
    }

    /**
     * （督导审核页面）根据督导选择店，月份，返回计算的（待审核，加上已审核通过的人员的应发工资总数）；
     * @author wjk
     * @Date 2021-11-23
     */
    @ResponseBody
    @PostMapping("/getShouldPayByDdSupervisorPost")
    public ResponseData getShouldPayByDdSupervisorPost(@RequestBody AttendAuditDdSupervisorParam param,String account){
        if(ToolUtil.isEmpty(param.getAccount())){
            param.setAccount(account);
        }
        Map<String,String> map = this.attendEmployeeMonthService.getShouldPayByDdSupervisor(param);
        return ResponseData.success(map);
    }
    /**
     * （店长考勤页面）根据店长手机号查询妖码；
     * @author wjk
     * @Date 2021-11-12
     */
    @ResponseBody
    @RequestMapping("/queryYaoMa")
    public ResponseData queryYaoMa(String account){

        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号。",new HashMap<String,String>());
        }
        Map<String,String> map = this.attendAuditBtyAreaService.queryYaoMa(account);
        return ResponseData.success(map);
    }

    /**
     * （店长考勤页面）根据店名，月份，返回计算的（待审核，加上已审核通过的人员的应发工资总数，和人员总数）；
     * @author wjk
     * @Date 2021-09-22
     */
    @ResponseBody
    @RequestMapping("/getShouldPayByDzInfo")
    public ResponseData getShouldPayByDzInfo(AttendAuditDdSupervisorParam param){
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(param.getAccount())) {
            return ResponseData.error(200,"缺少有效的手机号。",new HashMap<String,String>());
        }
        Map<String,String> map = this.attendEmployeeMonthService.getShouldPayByDzInfo(param);
        return ResponseData.success(map);
    }

    /**
     * （店长考勤修改页面）根据员工信息，计算员工考勤的月份的薪资信息
     * @author wjk
     * @Date 2021-09-28
     */
    @ResponseBody
    @PostMapping("/calculateEmployeeSalary")
    public ResponseData calculateEmployeeSalary(@RequestBody AttendAuditManagerSetResult attendAuditManagerSetResult,String account){
        AttendAuditManagerSetResult attendAuditManagerSetResultNew = this.attendEmployeeMonthService.calculateEmployeeSalary(attendAuditManagerSetResult,account);
        return ResponseData.success(attendAuditManagerSetResultNew);
    }

    /**
     * （督导审核界面）返回服务器当前应该审核的考勤月份和应该提交的月份
     * @author wjk
     * @Date 2021-09-29
     */
    @ResponseBody
    @RequestMapping("/getAttendMonth")
    public ResponseData getAttendMonth(){
        Map<String,String> map = this.attendAuditService.getAttendMonth();
        return ResponseData.success(map);
    }

    /**
     * （店长创建考勤页面）创建考勤界面，返回是否允许创建考勤信息
     * @author wjk
     * @Date 2021-09-30
     */
    @ResponseBody
    @RequestMapping("/getCreateAttendButton")
    public ResponseData getCreateAttendButton(){
        Map<String,String> map = this.attendAuditService.getCreateAttendButton();
        return ResponseData.success(map);
    }

    /**
     * （督导审核页面）根据督导的手机号码，和考核的月份返回该店的督导所有可审核的店名；
     * @author wjk
     * @Date 2021-10-08
     */
    @ResponseBody
    @RequestMapping("/getAttendAuditShowListByDdSupervisor")
    public ResponseData getAttendAuditShowListByDdSupervisor(AttendAuditDdSupervisorParam param){
        String[] stringArray =  this.attendEmployeeMonthService.getAttendAuditShowListByDdSupervisor(param);
        return ResponseData.success(stringArray);
    }

    /**
     * （督导审核页面）根据督导的手机号码，和考核的月份返回该店的督导所有可审核的店名；
     * @author wjk
     * @Date 2021-10-14
     */
    @ResponseBody
    @RequestMapping("/getAttendAuditShowListByDdSupervisorList")
    public ResponseData getAttendAuditShowListByDdSupervisorList(AttendAuditDdSupervisorParam param){
        List<Map<String,String>> stringList =  this.attendEmployeeMonthService.getAttendAuditShowListByDdSupervisorList(param);
        return ResponseData.success(stringList);
    }
    /**
     * （店长考勤修改页面）根据店长的手机号码，返回店长是应该跳转考勤页还是应该创建考勤页（若未创建考勤，状态为0，若已经创建了考勤，则状态为1）；
     * @author wjk
     * @Date 2021-10-12
     */
    @ResponseBody
    @RequestMapping("/getPageByDzPhone")
    public ResponseData getPageByDzPhone(String account,String attendMonth){
        //若手机号为空，则不用继续查询了，直接返回
        if (ToolUtil.isEmpty(account)) {
            return ResponseData.error(200,"缺少有效的手机号。",new HashMap<String,String>());
        }
        Map<String,String> map = this.attendEmployeeMonthService.getPageByDzPhone(account,attendMonth);
        return ResponseData.success(map);
    }

    /**
     * （运营经理页面）根据运营经理的手机号码，和考核的月份返回该店的运营经理所有可审核的店名；
     * @author wjk
     * @Date 2021-10-08
     */
    @ResponseBody
    @RequestMapping("/getAttendAuditShowListByYyjl")
    public ResponseData getAttendAuditShowListByYyjl(AttendAuditDdSupervisorParam param){
        List<Map<String,String>> stringList = this.attendEmployeeMonthService.getAttendAuditShowListByYyjl(param);
        return ResponseData.success(stringList);
    }

    /**
     * （运营经理页面）根据运营经理的手机号码，和考核的月份返回该店的运营经理所有可审核的店名；
     * @author wjk
     * @Date 2021-11-19
     */
    @ResponseBody
    @RequestMapping("/getAttendAuditShowListByYyjlLayuiPage")
    public ResponseData getAttendAuditShowListByYyjlLayuiPage(AttendAuditDdSupervisorParam param){
        LayuiPageInfo layuiPageInfo = this.attendEmployeeMonthService.getAttendAuditShowListByYyjlLayuiPage(param);
        return ResponseData.success(layuiPageInfo);
    }

    /**
     * （运营经理页面）根据督导选择店，月份，返回计算的（已审核通过的人员的应发工资总数）；
     * @author wjk
     * @Date 2021-10-08
     */
    @ResponseBody
    @RequestMapping("/getShouldPayByYyjl")
    public ResponseData getShouldPayByYyjl(AttendAuditDdSupervisorParam param){
        Map<String,String> map = this.attendEmployeeMonthService.getShouldPayByYyjl(param);
        return ResponseData.success(map);
    }

    /**
     * （运营经理页面）根据督导选择店，月份，返回计算的（已审核通过的人员的应发工资总数）；
     * @author wjk
     * @Date 2021-10-08
     */
    @ResponseBody
    @PostMapping("/getShouldPayByYyjlPost")
    public ResponseData getShouldPayByYyjlPost(@RequestBody AttendAuditDdSupervisorParam param,String account){
        if(ToolUtil.isEmpty(param.getAccount())){
            param.setAccount(account);
        }
        Map<String,String> map = this.attendEmployeeMonthService.getShouldPayByYyjl(param);
        return ResponseData.success(map);
    }
    /**
     * （店长考勤修改页面+重建考勤信息） 根据店长手机号，考勤的月份，重建店长当月的建考勤信息
     *
     *
     * @author wjk
     * @Date 2021-10-28
     */
    @ResponseBody
    @RequestMapping("/setEmployeeListByDzPhoneRestart")
    public ResponseData setEmployeeListByDzPhoneRestart(AttendAuditDdSupervisorParam attendAuditDdSupervisorParam) {
        //若电话为空，则返回吧
        if(ToolUtil.isEmpty(attendAuditDdSupervisorParam.getAccount())){
            return ResponseData.error(200,"缺少有效的手机号。",0);
        }
        //原来的同步弃用，不再使用，更改为对比之后的同步信息；
        //int size = this.attendEmployeeMonthService.setEmployeeListByDzPhoneRestart(attendAuditDdSupervisorParam);
        //根据对比的数据进行数据同步

        // 获取本月本店长的考勤状态，判断改状态下，能否同步，若不能同步，则提示，请督导驳回数据，之后进行同步
        AttendAudit attendAudit = this.attendAuditService.getAttendAuditByDzPhone(attendAuditDdSupervisorParam.getAccount());
        if(ToolUtil.isNotEmpty(attendAudit)&&ToolUtil.isNotEmpty(attendAudit.getId())){
            if(String.valueOf(attendAudit.getAuditStatus()).equals(String.valueOf(AttendAuditStatusEnum.SUBMIT_AUDIT.getCode()))||
                    String.valueOf(attendAudit.getAuditStatus()).equals(String.valueOf(AttendAuditStatusEnum.SUBMIT_THROUGH.getCode()))
                    ){
                return ResponseData.error(200, "该数据已经被提交，无法进行同步，若需要同步数据，请联系督导驳回相关信息。", 0);
            }
        }else{
            return ResponseData.error(200, "未找到审核信息，请确认当前日期是否在考勤时间，或者是否有相关权限。", 0);
        }
        int size = this.attendEmployeeMonthService.setEmployeeListByDzPhoneRestartForContrast(attendAuditDdSupervisorParam);
        if (size > 0) {
            return ResponseData.success(size);
        } else {
            return ResponseData.error(200, "暂无可同步的数据", size);
        }
    }

    /**
     * （店长考勤修改页面+重建考勤信息）同步页面对比工作
     *
     *
     * @author wjk
     * @Date 2021-11-08
     */
    @ResponseBody
    @RequestMapping("/contrastEmployeeListByDzPhoneRestart")
    public ResponseData contrastEmployeeListByDzPhoneRestart(AttendAuditManagerSetParam attendAuditManagerSetParam) {
        List<Map<String,AttendAuditManagerSetResult>> list = this.attendEmployeeMonthService.contrastEmployeeListByDzPhoneRestart(attendAuditManagerSetParam);
        if (list.size()> 0) {
            return ResponseData.success(list);
        } else {
            return ResponseData.error(200, "暂无可同步的数据", list);
        }
    }

    /**
     *
     *
     * (人员数据根据月度考勤表同步回人资档案表中)
     * @author wjk
     * @Date 2021-10-28
     */
    @ResponseBody
    @RequestMapping("/synchronousAttendEmployeeMonthToBtyArchives")
    public ResponseData synchronousAttendEmployeeMonthToBtyArchives(AttendAuditDdSupervisorParam param) {

        Map<String,String> map = this.attendEmployeeMonthService.synchronousAttendEmployeeMonthToBtyArchives(param);
        if (ToolUtil.isNotEmpty(map)) {
            return ResponseData.success(map);
        } else {
            return ResponseData.error(200, "失败", map);
        }
    }
    //getShouldPayByDdSupervisor

    /**
     *
     *
     * 推送微信消息，对所有已经设置店长的人员，本月未完成考勤的人员
     * @author wjk
     * @Date 2021-11-11
     */
    @ResponseBody
    @RequestMapping("/attendAuditPushMsgToIMAndWx")
    public ResponseData attendAuditPushMsgToIMAndWx() {

        Map<String,String> map = this.attendAuditService.attendAuditTimePushMsgToIMAndWx();
        if (ToolUtil.isNotEmpty(map)) {
            return ResponseData.success(map);
        } else {
            return ResponseData.error(200, "失败", map);
        }
    }



//    /**
//     * 同步员工的接口信息,
//     *
//     * @author wjk
//     * @Date 2021-10-29
//     */
//    @RequestMapping("/synchronousAttendEmployeeMonthById")
//    @ResponseBody
//    public ResponseData synchronousAttendEmployeeMonthById(String id) {
//
//        AttendEmployeeMonth attendEmployeeMonth = this.attendEmployeeMonthService.updateByAuditBtyArchivesId(id);
//
//        if(ToolUtil.isNotEmpty(attendEmployeeMonth)&&ToolUtil.isNotEmpty(attendEmployeeMonth.getId())){
//            return ResponseData.success(attendEmployeeMonth);
//        }else{
//            return ResponseData.error(200, "失败", attendEmployeeMonth);
//        }
//
//    }




    /**
     * 根据店长手机号，判断店长手下的员工的银行卡号是否正确，并验证银行卡是否重复
     * @author wjk
     * @Date 2021-12-17
     */
    @ResponseBody
    @PostMapping("/getYhkStatus")
    public ResponseData getYhkStatus(@RequestBody AttendEmployeeMonthParam attendEmployeeMonthParam,String account){
        if(ToolUtil.isEmpty(account)){
            return ResponseData.error(200, "缺少有效的手机号。",new HashMap<String,String>());
        }
        Map<String,String> map = this.attendEmployeeMonthService.getYhkStatus(attendEmployeeMonthParam,account);
//        if (ToolUtil.isNotEmpty(map)) {
//            return ResponseData.success(map);
//        } else {
//            return ResponseData.error(200, "失败", map);
//        }
        if (ToolUtil.isNotEmpty(map.get("flag"))) {
            if(map.get("flag").equals("true")){
                return ResponseData.success(map);
            }else{
                return ResponseData.error(200, map.get("msg"), map);
            }

        } else {
            return ResponseData.error(200, "银行卡号不正确，或者该银行卡处于异常状态，请重新输入银行卡号。", map);
        }
    }
}


